package com.liuzu.esys.controller;

import com.liuzu.esys.common.LayuiPageVo;
import com.liuzu.esys.common.R;
import com.liuzu.esys.pojo.Timecard;
import com.liuzu.esys.service.TimecardService;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author : 逸少
 * @time : 2022/7/26
 * @desc : 考勤列表操作
 */
@RestController
@RequestMapping("/timecard")
public class TimecardController {

    @Autowired
    private TimecardService timecardService;

    //分页显示信息和模糊
    @RequestMapping("/timecardList")
    public LayuiPageVo<Timecard> timecardLayPageVo (@RequestParam Map<String,Object> params) {
        System.out.println(params);
        return timecardService.timecardPagData(params);
    }
    //添加
    @RequestMapping("/addTimecard")
    public  R addTimecard(Timecard  timecard) {
        int result = timecardService.addTimecard(timecard);
        if (result == 1) {
            return R.ok();
        }
        return R.error();

    }

    //修改
    @RequestMapping("/timecardUpdata")
    public R timecardUpdata(Timecard timecard) {
        int i = timecardService.timecardUpdate(timecard);
        if (i == 1) {
            return R.ok();
        }
        return R.error();
    }

    //删除
    @RequestMapping("/timecardDelete")
    public R timecardDelete(int id) {
        int i = timecardService.timecardDelete(id);
        if (i == 1) {
            return R.ok();
        }
        return R.error();
    }



}
